﻿using OnlineDigitalCameraWebsite.Class;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

namespace OnlineDigitalCameraWebsite
{
    public partial class ThemVaoGioHang : System.Web.UI.Page
    {
        private Invoice _selectedInvoice = new Invoice();
        public Invoice SelectedInvoice
        {
            get
            {
                if (_selectedInvoice.InvoiceId == "")
                {
                    try
                    {
                        _selectedInvoice = (Invoice)Session["Invoice"];
                    }
                    catch { }
                }
                return _selectedInvoice;
            }
        }
        protected void Page_Load(object sender, EventArgs e)
        {
            int qty = 1;

            if (Request["qty"] != null)
            {
                qty = int.Parse(Request["qty"].ToString());
            }
            string id = Request["ID"].ToString();
            if (id != null)
            {
                try
                {
                    string ima = Session["lblimage"].ToString();
                    string cate = Request.QueryString["cate"].ToString();
                    //if (cate == "camera")
                    //{
                    //    Session["ProductCategory"] = "camera";
                    //}
                    //else if (cate == "accessories")
                    //{
                    //    Session["ProductCategory"] = "accessories";
                    //}
                    //else
                    //{
                    //    Session["ProductCategory"] = "accessories";
                    //}

                    SelectedInvoice.AddToInvoice(int.Parse(id), qty, ima, cate);
                }

                catch
                {

                }
            }
           
            Response.Redirect("GioHang.aspx");
        }
    }
}